]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
status/keyboard: Simplify MRU list updates
authorMaksim Mazko <undeparg@gmail.com>
Fri, 6 Mar 2026 13:20:10 +0000 (16:20 +0300)
committerFlorian Müllner <fmuellner@gnome.org>
Sat, 14 Mar 2026 17:49:13 +0000 (18:49 +0100)
Rewrite the update logic to a more direct form, improving readability by
removing the manual iteration and list manipulation.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/4101>
(cherry picked from commit fcba3bd44ec0362a26f456ff1ba2321d6b16594c)

js/ui/status/keyboard.js

index 96f0dff0fcb54d9cb850f7822f09e038dbc73b63..81e2d5daf0c1bc1bd7f15bdbd2a2195c2a4f5a27 100644 (file)
@@ -487,13 +487,11 @@ export class InputSourceManager extends Signals.EventEmitter {
 
         this.emit('current-source-changed', oldSource);
 
-        for (let i = 1; i < this._mruSources.length; ++i) {
-            if (this._mruSources[i] === newSource) {
-                let currentSource = this._mruSources.splice(i, 1);
-                this._mruSources = currentSource.concat(this._mruSources);
-                break;
-            }
-        }
+        this._mruSources = [
+            newSource,
+            ...this._mruSources.filter(s => s !== newSource),
+        ];
+
         this._changePerWindowSource();
     }